<?php

namespace App\Http\Requests\Admin\TaskServiceType;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreTaskServiceTypeRequest extends FormRequest
{
    public function authorize(): bool
    {
        return (bool) $this->user('admin');
    }

    public function rules(): array
    {
        return [
            'name' => [
                'required',
                'string',
                'max:100',
                Rule::unique('task_service_types', 'name'),
            ],
        ];
    }

    public function messages(): array
    {
        return [
            'name.required' => '请填写服务类型名称',
            'name.unique' => '该服务类型已存在',
        ];
    }
}
